package org.zcl.单例;

import java.io.ObjectStreamException;

/**
 * @PROJECT_NAME:
 * @DESCRIPTION: 饱汉，双重校验
 * @USER: ZhuChengLin
 * @DATE: 2021/11/22 10:16
 */
public class Single4 {

    private volatile static Single4 single4;

    private Single4() {
    }

    public static Single4 getInstance() {
        if (single4 == null) {
            synchronized (Single4.class) {
                if (single4 == null) {
                    single4 = new Single4();
                }
            }
        }
        return single4;
    }

    private Object readResolve() throws ObjectStreamException {
        return single4;
    }
}
